package com.compass.doctor.ui.home.view

import android.content.Context
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.compass.doctor.databinding.ViewLatestBuyerBinding
import com.compass.doctor.ui.home.LatestBuyerActivity
import com.compass.doctor.ui.home.adapter.LatestBuyerAdapter
import com.compass.framework.ext.onClick
import com.compass.framework.model.OrderSpecial

/**
 * Description： 最新购买的人
 * Date:2023/12/23 21:59
 */
class LatestBuyerView (context: Context?) : LinearLayout(context) {

    private var latestBuyerAdapter :LatestBuyerAdapter
    private var viewLatestBuyerBinding:ViewLatestBuyerBinding?=null

    init {
        viewLatestBuyerBinding =
            ViewLatestBuyerBinding.inflate(LayoutInflater.from(context), this, true)
        latestBuyerAdapter = LatestBuyerAdapter(1)
        viewLatestBuyerBinding?.apply {
            rcyLatestBuyer.apply {
                layoutManager = LinearLayoutManager(context)
                adapter = latestBuyerAdapter

            }
            ivMoreAction.onClick { 
                context?.let { LatestBuyerActivity.start(it) }
            }
        }

    }


    /**
     * 设置内容，自行扩展
     */
    fun initData( commentList:MutableList<OrderSpecial>) {
        latestBuyerAdapter.setData(commentList)
    }
}